package com.caiden_micheal.dynamic.form.web;

import com.caiden_micheal.base.domain.AjxResult;
import com.caiden_micheal.dynamic.form.dto.*;
import com.caiden_micheal.dynamic.form.service.DFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dform")
public class DFormController {

    @Autowired
    private DFormService dFormService;

    @PostMapping("/addDForm")
    public AjxResult addDForm(@RequestBody AddDFormDTO addDFormDTO) {
        return dFormService.addDForm(addDFormDTO);
    }

    @PostMapping("/removeDForm")
    public AjxResult removeDForm(@RequestBody RemoveDFormDTO removeDFormDTO) {
        return dFormService.removeDForm(removeDFormDTO);
    }

    @PostMapping("/findDFormPageQuery")
    public AjxResult findDFormPageQuery(@RequestBody FindDFormPageQueryDTO findDFormPageQueryDTO) {
        return AjxResult.success(dFormService.findDFormByCondition(findDFormPageQueryDTO));
    }

    @PostMapping("/findDFormOne")
    public AjxResult findDFormOne(@RequestBody FindDFormOneDTO findDFormOneDTO) {
        return dFormService.findDFormOne(findDFormOneDTO);
    }

    @PostMapping("/findFormSelectData")
    public AjxResult findFormSelectData(@RequestBody FindFormSelectDataDTO findFormSelectDataDTO) {
        return dFormService.findFormSelectData(findFormSelectDataDTO);
    }
}
